package com.qidian.mes.defect.controller;

import com.qidian.mes.defect.service.TemplateService;
import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.pojo.Detection;
import com.qidianit.mes.pojo.Template;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 泽华
 * @Description
 * @Time 2024-10-21 23:46
 */
@RestController
@CrossOrigin
@RequestMapping("/template")

public class TemplateController {
    @Autowired
    private TemplateService templateService;
    @GetMapping("/list")
    public MESResult list(Long templateId, String detectionName, String templateType,
                          @RequestParam(defaultValue = "1")int page,
                          @RequestParam(defaultValue = "10") int limit){
        return templateService.list(templateId,detectionName,templateType,page,limit);
    }

    @PostMapping("/save")
    public MESResult save(@RequestBody Template template){
        return templateService.save(template);
    }


    @DeleteMapping("/delete")
    public MESResult delete(Long templateId){
        return templateService.delete(templateId);
    }

    @PutMapping("/update")
    public MESResult update(@RequestBody Template template){
        return templateService.update(template);
    }

    //通过id查询这条数据
    @GetMapping("/get")
    public MESResult get(Long templateId){
        return templateService.selectById(templateId);
    }

}
